alter table lullabyusuari alter column username varchar(50) null
GO
alter table lullabyusuari alter column password varchar(50) null
GO



/****** Object:  Index [IX_LullabyUsuariUserNamePassword]    Script Date: 02/19/2013 23:32:44 ******/
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[LullabyUsuari]') AND name = N'IX_LullabyUsuariUserNamePassword')
DROP INDEX [IX_LullabyUsuariUserNamePassword] ON [dbo].[LullabyUsuari] WITH ( ONLINE = OFF )
GO


/****** Object:  Index [IX_LullabyUsuariUserNamePassword]    Script Date: 02/19/2013 23:32:54 ******/
CREATE UNIQUE NONCLUSTERED INDEX [IX_LullabyUsuariUserNamePassword] ON [dbo].[LullabyUsuari] 
(
	[UserName] ASC,
	[Password] ASC
) where username is not null and password is not null
WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

GO


CREATE TABLE [dbo].[LullabyNeteja](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Data] [date] NOT NULL,
	[HoraObertura] [time](7) NOT NULL,
	[HoraTancament] [time](7) NULL,
	[IdHostal] [int] NOT NULL,
	[IdUsuariNeteja] [int] NOT NULL,
	[IdUsuariObertura] [int] NOT NULL,
	[IdUsuariTancament] [int] NULL,
	[Observacions] [nvarchar](150) NULL,
 CONSTRAINT [PK_LullabyNeteja] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[LullabyNeteja]  WITH CHECK ADD  CONSTRAINT [FK_LullabyNeteja_LullabyHostal] FOREIGN KEY([IdHostal])
REFERENCES [dbo].[LullabyHostal] ([Id])
GO

ALTER TABLE [dbo].[LullabyNeteja] CHECK CONSTRAINT [FK_LullabyNeteja_LullabyHostal]
GO

ALTER TABLE [dbo].[LullabyNeteja]  WITH CHECK ADD  CONSTRAINT [FK_LullabyNeteja_LullabyUsuari] FOREIGN KEY([IdUsuariNeteja])
REFERENCES [dbo].[LullabyUsuari] ([Id])
GO

ALTER TABLE [dbo].[LullabyNeteja] CHECK CONSTRAINT [FK_LullabyNeteja_LullabyUsuari]
GO

ALTER TABLE [dbo].[LullabyNeteja]  WITH CHECK ADD  CONSTRAINT [FK_LullabyNeteja_LullabyUsuari1] FOREIGN KEY([IdUsuariObertura])
REFERENCES [dbo].[LullabyUsuari] ([Id])
GO

ALTER TABLE [dbo].[LullabyNeteja] CHECK CONSTRAINT [FK_LullabyNeteja_LullabyUsuari1]
GO

ALTER TABLE [dbo].[LullabyNeteja]  WITH CHECK ADD  CONSTRAINT [FK_LullabyNeteja_LullabyUsuari2] FOREIGN KEY([IdUsuariTancament])
REFERENCES [dbo].[LullabyUsuari] ([Id])
GO

ALTER TABLE [dbo].[LullabyNeteja] CHECK CONSTRAINT [FK_LullabyNeteja_LullabyUsuari2]
GO


